package com.smartpay.its.framework.remoting.hessian.server;

import javax.servlet.ServletConfig;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

/**
 * 
 * 从web application中读取Spring ApplicationContext初始化Hessian服务
 * 
 * @author 谢芝伟
 * 
 */
public class HessianDispatcherServletFromContext extends
		HessianDispatcherServlet {
	
	private static final Logger logger = LoggerFactory.getLogger(HessianDispatcherServletFromContext.class);

	/**
	 * 
	 */
	private static final long serialVersionUID = 4602521544836935039L;

	/**
	 * 初始化hessian service manager
	 * 
	 * @param springConfig
	 */
	protected void initSpringContext(String springConfig, ServletConfig config) {

		WebApplicationContext context = WebApplicationContextUtils
				.getRequiredWebApplicationContext(config.getServletContext());
		serviceManager = (IHessianServiceManager) context
				.getBean("hessianServiceManager");
		logger.info("System initialized.");

	}
}